<?php use_helper('Date'); ?>

<h1><?php echo $tache->getTacLibelle(); ?></h1>

<div class="action">
<?php 
	// modifier
	echo link_to('Modifier', 'tache/edit?tac_id='.$tache->getTacId(), array('class' => 'action'));
	
	// supprimer
	if ($tache->isSupprimable()) {
		echo ' &nbsp; ';
		echo link_to('Supprimer', 'tache/delete?tac_id='.$tache->getTacId(), array('method' => 'delete', 'confirm' => 'Etes-vous sûr ?', 'class' => 'action')) ;
	}
	
	if (!$tache->isFils()) {
		// créer une tache fille
		echo ' &nbsp; ';
		echo link_to('Ajouter tâche liée', 'tache/new?parent='.$tache->getTacId(), array('class' => 'action'));
		
		// créer un événement
		echo ' &nbsp; ';
		echo link_to('Ajouter événement', 'evenement/new_tache?tac_id='.$tache->getTacId(), array('class' => 'action'));
		
		// créer une note
		echo ' &nbsp; ';
		echo link_to('Ajouter note', 'note/new_tache?tac_id='.$tache->getTacId(), array('class' => 'action'));
	}
?>
</div>


<div class="section">
<h2>Définition</h2>

<table class="detail">
	<tr>
		<th>Catégorie</th>
		<td><?php echo $tache->getCategorie() ?></td>
	</tr>
	<tr>
		<th>Tâche</th>
		<td><?php echo $tache->getTacLibelle() ?></td>
	</tr>
	<?php if ($tache->isFils()): ?>
	<tr>
		<th>Tâche parente</th>
		<td><?php echo link_to($tache->getTachePere()->getTacLibelle(), 'tache/show?tac_id='.$tache->getTachePere()->getTacId()) ?></td>
	</tr>
	<?php endif; ?>
	<tr>
		<th>Description</th>
		<td><?php echo str_replace("\n", "<br/>", $tache->getTacDescription()) ?></td>
	</tr>
	<tr>
		<th>Urgence</th>
		<td><?php echo $tache->getUrgence() ?></td>
	</tr>
	<tr>
		<th>Etat</th>
		<td><?php echo $tache->getEtat() ?></td>
	</tr>
</table>
</div>



<div class="section">
<h2>Actions</h2>

<div class="form">
<?php 
	include_partial('form_charge', array('form' => $form));
?>
</div>
</div>



<?php if ($tache->isPere()): ?>
<div class="section">
<h2>Tâches liées</h2>

<?php 
	$tache_list = $tache->getTachesFils();
	include('liste.php'); 
?>

</div>
<?php endif; ?>


<div class="section">
<h2>Evénements</h2>
<table class="detail-liste">
<?php 
	$evt_list = $tache->getEvenements(); 
	foreach ($evt_list as $evenement) {
		echo '<tr>';
		echo '<td class="action"><a href="'. url_for('evenement/edit_tache?evt_id='.$evenement->getTacevtId()) .'">'. image_tag('edit.png') .'</a></td>';
		echo '<td>'. format_date($evenement->getTacevtDate(), 'dd/MM/yyyy') .'</td>';
		echo '<td>'. $evenement->getTacevtEvenement().'</td>';
		echo '</tr>';
	}
?>
</table>
<?php echo link_to('Nouvel evenement', 'evenement/new_tache?tac_id='.$tache->getTacId(), array('class' => 'action')) ?>
</div>


<div class="section">
<h2>Notes</h2>
<table class="detail-liste">
<?php 
	$note_list = $tache->getNotes(); 
	foreach ($note_list as $note) {
		echo '<tr>';
		echo '<td class="action"><a href="'. url_for('note/edit_tache?nte_id='.$note->getTacnteId()) .'">'. image_tag('edit.png') .'</a></td>';
		echo '<td>'. format_date($note->getTacnteDate(), 'dd/MM/yyyy') .'</td>';
		echo '<td>'. $note->getTacnteNote().'</td>';
		echo '</tr>';
	}
?>
</table>
<?php echo link_to('Nouvelle note', 'note/new_tache?tac_id='.$tache->getTacId(), array('class' => 'action')) ?>
</div>




<div class="section">
<h2>Attributs</h2>

<table class="detail">

	<tr><th class="sous_titre" colspan="2">Jalons</th></tr>
	<tr>
		<th>Date de début</th>
		<td><?php echo format_date($tache->getTacDateDebut(), 'dd/MM/yyyy') ?></td>
	</tr>
	<tr>
		<th>Date échéance</th>
		<td><?php if ($tache->getTacDateEcheance() <> '0000-00-00 00:00:00') echo format_date($tache->getTacDateEcheance(), 'dd/MM/yyyy') ?></td>
	</tr>
	<tr>
		<th>Date fin</th>
		<td><?php if ($tache->getTacDateFin() <> '0000-00-00 00:00:00') echo format_date($tache->getTacDateFin(), 'dd/MM/yyyy') ?></td>
	</tr>

	
	<tr><th class="sous_titre" colspan="2">Charges</th></tr>
	<tr>
		<th>Charge estimée</th>
		<td><?php echo $tache->getTacChargeEstimee() ?></td>
	</tr>
	<tr>
		<th>Charge consommée</th>
		<td><?php echo $tache->getTacChargeConsommee() ?></td>
	</tr>
	<tr>
		<th>Charge restante</th>
		<td><?php echo $tache->getTacChargeRestante() ?></td>
	</tr>
	<tr>
		<th>Avancement</th>
		<td><?php printf('%d%%', round($tache->getAvancement()*100, 0)) ?></td>
	</tr>
	<tr>
		<th>Dépassement</th>
		<td><?php printf('%d%%', round($tache->getDepassement()*100, 0)) ?></td>
	</tr>

	
	<tr><th class="sous_titre" colspan="2">Historique</th></tr>
<?php 
	$hst_list = $tache->getHistoriques(); 
	foreach ($hst_list as $hst) {
		echo '<tr>';
		echo '<th>'. format_date($hst->getHstDate(), 'dd/MM/yyyy') .'</th>';
		echo '<td>'. $hst.'</td>';
		echo '</tr>';
	}
?>
</table>
</div>

